//
//  JHCharacterTableViewCell.m
//  Liberty Voice
//
//  Created by dlios on 15-5-13.
//  Copyright (c) 2015年 ClearLove. All rights reserved.
//

#import "JHCharacterTableViewCell.h"

@implementation JHCharacterTableViewCell
- (void)dealloc
{
    [_myLabel1 release];
    [_myImageView1 release];
    [super dealloc];
}
/**
 *  2.重写初始化方法
 *
 */
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{

        if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
            self.myImageView1 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"123"]];
            [self.contentView addSubview:_myImageView1];
            
            
            self.myLabel1 = [[UILabel alloc] init];
            _myLabel1.numberOfLines = 0;
//            _myLabel1.backgroundColor = [UIColor redColor];
            [_myLabel1 sizeToFit];
            _myLabel1.font = [UIFont systemFontOfSize:17];
            [self.myImageView1 addSubview:_myLabel1];
            [_myLabel1 release];
    
        
    }
    return self;
}
/**
 *  3. 设置cell上控件的frame
 */


+ (CGFloat)heightWithText:(NSString *)text
{
        NSDictionary *dic = @{NSFontAttributeName:[UIFont systemFontOfSize:17]};
        CGSize size = CGSizeMake(330, 1000);
        CGRect rect = [text boundingRectWithSize:size options:NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil];
        return rect.size.height;
}
- (void)layoutSubviews
{
        [super layoutSubviews];
        _myImageView1.frame = CGRectMake(5, 10, self.contentView.frame.size.width - 10, self.contentView.frame.size.height - 15);
        CGFloat f1 = [[self class] heightWithText:_myLabel1.text];
//    NSLog(@"=========%@", _myLabel1.text);
        _myLabel1.frame = CGRectMake(15, 10, self.myImageView1.frame.size.width - 30, f1);
        
        
}
//- (void)setJhoc:(JHCharacterObject *)jhoc
//{
//    if (jhoc != _jhoc) {
//        [_jhoc release];
//        _jhoc = [jhoc retain];
//    }
//    _myLabel1.text = jhoc.JHText;
//}


- (void)awakeFromNib {
    // Initialization code
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
